/**  
 * @Title: UserController.java
 * @Package org.wk.user.controller
 * @Description: TODO【】
 * @author df.w 
 * @date 2018年5月3日 下午2:40:54
 * @version V1.0  
 */ 

package org.wk.user.api.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.wk.core.common.view.ResponseVo;
import org.wk.user.service.AttendancesService;
import org.wk.user.service.UserPromoteRelationService;
import org.wk.user.service.UserService;

import com.alibaba.fastjson.JSONObject;
import org.wk.user.service.UserSuggestionsService;

/**
 * @ClassName	: UserController
 * @Package		：org.wk.user.controller
 * @Author df.w 
 * @Create Time	：2018年5月3日 下午2:40:54
 * @Description	: 
 */
@RestController
public class UserController {

	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private UserService userService;

	@Autowired
	private AttendancesService attendancesService;
	
	@Autowired
	private UserPromoteRelationService userPromoteRelationService;
	@Autowired
	private UserSuggestionsService userSuggestionsService;

	/**
	 * @Title		: usersProfile
	 * @Param		: @return
	 * @Return Type 	：String
	 * @Description	: 获取用户信息
	 */ 
	@RequestMapping(value="/users/profile",method=RequestMethod.POST,produces=MediaType.APPLICATION_JSON_UTF8_VALUE)
	public String usersProfile() {
		logger.info("获取用户信息>>>>{}");
		ResponseVo responseVo = userService.profile();
		logger.info("获取用户信息返回值>>>>{}",responseVo.toString());
		return responseVo.toString();
		
	}
	
	
	
	/**
	 * @Title		: updateUsersProfile
	 * @Param		: @param jsonObject
	 * @Param		: @return
	 * @Return Type 	：String
	 * @Description	: 修改用户资料
	 */ 
	@RequestMapping(value="/users/updateProfile",method=RequestMethod.POST,produces=MediaType.APPLICATION_JSON_UTF8_VALUE)
	public String updateUsersProfile(@RequestBody JSONObject jsonObject) {
		logger.info("修改用户信息>>>>{}",jsonObject);
		ResponseVo responseVo = userService.updateProfile(jsonObject);
		logger.info("修改用户信息返回值>>>>{}",responseVo.toString());
		return responseVo.toString();
		
	}
	
	
	/**
	 * @Title		: reset_password_via_oldpassword
	 * @Param		: @param jsonObject
	 * @Param		: @return
	 * @Return Type 	：String
	 * @Description	: 通过旧密码修改登录密码
	 */ 
	@RequestMapping(value="/passwords/login_password/reset_password_via_oldpassword",method=RequestMethod.POST,produces=MediaType.APPLICATION_JSON_UTF8_VALUE)
	public String reset_password_via_oldpassword(@RequestBody JSONObject jsonObject) {
		logger.info("修改登录密码>>>>{}",jsonObject.toString());
		ResponseVo responseVo = userService.updateLoginPassword(jsonObject);
		logger.info("修改登录密码返回值>>>>{}",responseVo.toString());
		return responseVo.toString();
		
	}
	
	
	
	/**
	 * @Title		: verifyIDCard
	 * @Param		: @param jsonObject
	 * @Param		: @return
	 * @Return Type 	：String
	 * @Description	: 实名认证身份证
	 */ 
	@RequestMapping(value="/users/verify/idcard",method=RequestMethod.POST,produces=MediaType.APPLICATION_JSON_UTF8_VALUE)
	public String verifyIDCard(@RequestBody JSONObject jsonObject) {
		logger.info("实名认证身份证>>>>{}",jsonObject.toString());
		ResponseVo responseVo = userService.verifyIDCard(jsonObject);
		logger.info("实名认证身份证返回值>>>>{}",responseVo.toString());
		return responseVo.toString();
		
	}

	/**
	 * @Title		: verifyVipPassList
	 * @Param		: @return
	 * @Return Type 	：String
	 * @Description	: vip升级已审核数据
	 */
	@RequestMapping(value="/users/verify/verifyVipPassList",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_UTF8_VALUE)
	public String verifyVipPassList() {
		logger.info("vip升级待审核数据>>>>{}");
		ResponseVo responseVo = userService.verifyVipPassList();
		logger.info("vip升级待审核数据返回值>>>>{}",responseVo.toString());
		return responseVo.toString();
	}

	/**
	 * @Title		: verifyVipList
	 * @Param		: @param jsonObject
	 * @Param		: @return
	 * @Return Type 	：String
	 * @Description	: vip升级待审核数据
	 */
	@RequestMapping(value="/users/verify/verifyVipList",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_UTF8_VALUE)
	public String verifyVipList() {
		logger.info("vip升级待审核数据>>>>{}");
		ResponseVo responseVo = userService.verifyVipList();
		logger.info("vip升级待审核数据返回值>>>>{}",responseVo.toString());
		return responseVo.toString();
	}

	/**
	 * @Title		: verifyVip
	 * @Param		: @param jsonObject
	 * @Param		: @return
	 * @Return Type 	：String
	 * @Description	: vip升级审核
	 */
	@RequestMapping(value="/users/verify/verifyVip",method=RequestMethod.POST)
	public String verifyVip(@RequestBody JSONObject jsonObject) {
		logger.info("vip升级审核>>>>{}",jsonObject.toString());
		ResponseVo responseVo = userService.verifyVip(jsonObject);
		logger.info("vip升级审核返回值>>>>{}",responseVo.toString());
		return responseVo.toString();

	}

	/**
	 * @Title		: identityVip
	 * @Param		: @param jsonObject
	 * @Param		: @return
	 * @Return Type 	：String
	 * @Description	: 申请成为vip
	 */
	@RequestMapping(value="/users/identity/vip",method=RequestMethod.POST,produces=MediaType.APPLICATION_JSON_UTF8_VALUE)
	public String identityVip() {
		logger.info("申请成为vip>>>>{}");
		ResponseVo responseVo = userService.applyForVip();
		logger.info("申请成为vip>>>>{}",responseVo.toString());
		return responseVo.toString();

	}

	/**
	 * @Description 获取VIP申请状态
	 * @param
	 * @author ZhaoPing'an
	 * @Date 2018/6/21 17:10
	 */
	@RequestMapping(value="/users/identity/vipApplyStatus",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_UTF8_VALUE)
	public String vipApplyStatus() {
		logger.info("获取VIP申请状态>>>>{}");
		ResponseVo responseVo = userService.findVipApplyStatus();
		logger.info("获取VIP申请状态返回结果>>>>{}",responseVo.toString());
		return responseVo.toString();

	}

	/**
	 *
	 * 我的团队
	 * @param
	 * @return
	 */
	@RequestMapping(value="/users/promote/team",method=RequestMethod.POST,produces=MediaType.APPLICATION_JSON_UTF8_VALUE)
	public String promoteTeam(@RequestParam(required = false,defaultValue = "1") Integer page_num, @RequestParam(required = false,defaultValue = "150") Integer page_size) {
 		logger.info("我的团队>>>>{}");
		ResponseVo responseVo = userPromoteRelationService.myTeam(page_num,page_size);
		logger.info("团队>>>>{}",responseVo.toString());
		return responseVo.toString();
	}

	/**
	 * @Description 获取当前用户签到状态
	 * @Param [jsonObject]
	 * @author ZhaoPing'an
	 * @Date 2018/5/21 15:11
	 */
	@RequestMapping(value="/attendances",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_UTF8_VALUE)
	public String getSignStatus() {
		logger.info("获取用户签到状态>>>>{}");
		ResponseVo responseVo = attendancesService.getSignStatus();
		logger.info("获取用户签到状态结果>>>>{}",responseVo.toString());
		return responseVo.toString();
	}

	/**
	 * @Description 签到
	 * @Param []
	 * @author ZhaoPing'an
	 * @Date 2018/5/21 17:10
	 */
	@RequestMapping(value="/attendances",method=RequestMethod.POST,produces=MediaType.APPLICATION_JSON_UTF8_VALUE)
	public String attendances() {
		logger.info("用户签到>>>>{}");
		ResponseVo responseVo = attendancesService.sign();
		logger.info("用户签到结果>>>>{}",responseVo.toString());
		return responseVo.toString();
	}

	/**
	 * 用户意见反馈
	 * @author TangShenShen
	 * @date 2018/5/29 17:09
	 */
	@RequestMapping(value="/suggestions",method=RequestMethod.POST,produces=MediaType.APPLICATION_JSON_UTF8_VALUE)
	public String suggestions(@RequestBody JSONObject jsonObject) {
		logger.info("用户意见反馈>>>>{}");
		ResponseVo responseVo = userSuggestionsService.saveUserSuggestions(jsonObject);
		logger.info("用户意见反馈结果>>>>{}",responseVo.toString());
		return responseVo.toString();
	}

	/*
	 * @description 设置二级密码
	 * @param
	 * @author ZhaoPing'an
	 * @date 2018/8/10 9:53
	 */
	@RequestMapping(value="/level_two_password/setting_by_smscode",method=RequestMethod.POST,produces=MediaType.APPLICATION_JSON_UTF8_VALUE)
	public String setLevelTwoPassword(@RequestBody JSONObject jsonObject) {
		logger.info("设置二级密码>>>{}");
		ResponseVo responseVo =  userService.settingLevelTwoPassword(jsonObject);
		logger.info("设置二级密码结果>>>>{}",responseVo.toString());
		return responseVo.toString();
	}

	/*
	 * @description 修改二级密码
	 * @param
	 * @author ZhaoPing'an
	 * @date 2018/8/10 9:53
	 */
	@RequestMapping(value="/level_two_password/update",method=RequestMethod.POST,produces=MediaType.APPLICATION_JSON_UTF8_VALUE)
	public String updateLevelTwoPassword(@RequestBody JSONObject jsonObject) {
		logger.info("修改二级密码>>>{}");
		ResponseVo responseVo =  userService.updateLevelTwoPassword(jsonObject);
		logger.info("修改二级密码结果>>>>{}",responseVo.toString());
		return responseVo.toString();
	}

}
